package model

import (
	"gorm.io/gorm"
	"time"
)


type Account struct {
	ID         int64          `gorm:"primary_key;column:ID;type:bigint(20);not null" json:"id"`
	Name       string         `gorm:"column:name;type:varchar(64);not null" json:"name"`
	Phone      string         `gorm:"unique;column:phone;type:varchar(64);not null" json:"phone"`
	Email      string         `gorm:"column:email;type:varchar(128);not null" json:"email"`
	RegisterIP string         `gorm:"column:register_ip;type:varchar(64);not null" json:"register_ip"`
	State      int            `gorm:"column:state;type:int(11);not null" json:"state"`
	CompanyID  int64          `gorm:"column:company_id;type:bigint(20);not null" json:"company_id"`
	Avatar     string         `gorm:"column:avatar;type:varchar(256);not null" json:"avatar"`
	WxOpenid   string         `gorm:"column:wx_openid;type:varchar(128);not null" json:"wx_openid"`
	CreatedAt  time.Time      `gorm:"column:created_at;type:datetime;not null" json:"created_at"`
	UpdatedAt  time.Time      `gorm:"column:updated_at;type:datetime;not null" json:"updated_at"`
	DeletedAt  gorm.DeletedAt `gorm:"column:deleted_at;type:datetime" json:"deleted_at"`
}


type AccountActive struct {
	ID        int64     `gorm:"primary_key;column:ID;type:bigint(20);not null" json:"id"`
	Token     string    `gorm:"column:token;type:varchar(256);not null" json:"token"`
	CreatedAt time.Time `gorm:"column:created_at;type:datetime;not null" json:"created_at"`
	UpdatedAt time.Time `gorm:"column:updated_at;type:datetime;not null" json:"updated_at"`
}


type AccountAuth struct {
	ID         int64     `gorm:"primary_key;column:ID;type:bigint(20);not null" json:"id"`
	AccountID  int64     `gorm:"column:account_id;type:bigint(20);not null" json:"account_id"`
	Type       int       `gorm:"column:type;type:int(11);not null" json:"type"`
	IDentifier string    `gorm:"column:identifier;type:varchar(512);not null" json:"identifier"`
	Credential string    `gorm:"column:credential;type:varchar(512);not null" json:"credential"`
	CreatedAt  time.Time `gorm:"column:created_at;type:datetime;not null" json:"created_at"`
	UpdatedAt  time.Time `gorm:"column:updated_at;type:datetime;not null" json:"updated_at"`
}


type AccountLog struct {
	ID          int64     `gorm:"primary_key;column:ID;type:bigint(20);not null" json:"id"`
	Type        int       `gorm:"column:type;type:int(11);not null" json:"type"`
	AccountID   int64     `gorm:"column:account_id;type:bigint(20);not null" json:"account_id"`
	AccountName string    `gorm:"column:account_name;type:varchar(64);not null" json:"account_name"`
	IP          string    `gorm:"column:ip;type:varchar(64);not null" json:"ip"`
	Result      string    `gorm:"column:result;type:varchar(32);not null" json:"result"`
	CreatedAt   time.Time `gorm:"column:created_at;type:datetime;not null" json:"created_at"`
	UpdatedAt   time.Time `gorm:"column:updated_at;type:datetime;not null" json:"updated_at"`
}


type AccountRole struct {
	ID        int64          `gorm:"primary_key;column:ID;type:bigint(20);not null" json:"id"`
	AccountID int64          `gorm:"column:account_id;type:bigint(20);not null" json:"account_id"`
	RoleID    int64          `gorm:"column:role_id;type:bigint(20);not null" json:"role_id"`
	CreatedAt time.Time      `gorm:"column:created_at;type:datetime;not null" json:"created_at"`
	UpdatedAt time.Time      `gorm:"column:updated_at;type:datetime;not null" json:"updated_at"`
	DeletedAt gorm.DeletedAt `gorm:"column:deleted_at;type:datetime" json:"deleted_at"`
}


type PhoneCaptcha struct {
	ID        int64          `gorm:"primary_key;column:ID;type:bigint(20);not null" json:"id"`
	Phone     string         `gorm:"column:phone;type:varchar(64);not null" json:"phone"`
	Untitled  string         `gorm:"column:untitled;type:varchar(32)" json:"untitled"`
	CreatedAt time.Time      `gorm:"column:created_at;type:datetime;not null" json:"created_at"`
	UpdatedAt time.Time      `gorm:"column:updated_at;type:datetime;not null" json:"updated_at"`
	DeletedAt gorm.DeletedAt `gorm:"column:deleted_at;type:datetime" json:"deleted_at"`
}


type Resource struct {
	ID          int64          `gorm:"primary_key;column:ID;type:bigint(20);not null" json:"id"`
	Name        string         `gorm:"unique;column:name;type:varchar(128);not null" json:"name"`
	Description string         `gorm:"column:description;type:varchar(256);not null" json:"description"`
	URL         string         `gorm:"column:url;type:varchar(256);not null" json:"url"`
	Method      string         `gorm:"column:method;type:varchar(32);not null" json:"method"`
	Type        string         `gorm:"column:type;type:varchar(32);not null" json:"type"`
	CreatedAt   time.Time      `gorm:"column:created_at;type:datetime;not null" json:"created_at"`
	UpdatedAt   time.Time      `gorm:"column:updated_at;type:datetime;not null" json:"updated_at"`
	DeletedAt   gorm.DeletedAt `gorm:"column:deleted_at;type:datetime" json:"deleted_at"`
}


type Role struct {
	ID          int64          `gorm:"primary_key;column:ID;type:bigint(20);not null" json:"id"`
	Name        string         `gorm:"unique;column:name;type:varchar(128);not null" json:"name"`
	Description string         `gorm:"column:description;type:varchar(128);not null" json:"description"`
	Duty        string         `gorm:"column:duty;type:varchar(128);not null" json:"duty"`
	CreatedAt   time.Time      `gorm:"column:created_at;type:datetime;not null" json:"created_at"`
	UpdatedAt   time.Time      `gorm:"column:updated_at;type:datetime;not null" json:"updated_at"`
	DeletedAt   gorm.DeletedAt `gorm:"column:deleted_at;type:datetime" json:"deleted_at"`
}


type RoleResource struct {
	ID         int64          `gorm:"primary_key;column:ID;type:bigint(20);not null" json:"id"`
	RoleID     int64          `gorm:"column:role_id;type:bigint(20);not null" json:"role_id"`
	ResourceID int64          `gorm:"column:resource_id;type:bigint(20);not null" json:"resource_id"`
	CreatedAt  time.Time      `gorm:"column:created_at;type:datetime;not null" json:"created_at"`
	UpdatedAt  time.Time      `gorm:"column:updated_at;type:datetime;not null" json:"updated_at"`
	DeletedAt  gorm.DeletedAt `gorm:"column:deleted_at;type:datetime" json:"deleted_at"`
}
